package cn.yunhe.controll;

import java.util.List;

import cn.yunhe.model.House;
import cn.yunhe.model.UserRegs;
import cn.yunhe.services.SerRent;
import cn.yunhe.until.PageUtil;

public class GuanLiAction extends BaseAction {

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;



	private List<House> house;
	private int currPage;
	private String pageIndex;
	private String id;
	   
	SerRent serRent = new SerRent();
	  
	   public String guanli() {
		   //获得当前页
		
		   if("".equals(pageIndex)||pageIndex==null) {
			   pageIndex="1";
		   }
		   currPage = Integer.parseInt(pageIndex);
		   
		   int count = serRent.getCount();
		   
		   int totalPage = PageUtil.pageCount(count,PageUtil.pageSize);
		   
		   if (currPage < 1) {
				currPage = 1;
			} else if (currPage > totalPage) {
				currPage = totalPage;
			}
		   
		  /* UserRegs userRegs =(UserRegs)getSession().getAttribute("userRegs");
	        int uid =userRegs.getUid();
		    System.out.println(uid);
		    house = serRent.selAll(uid);
		    */
		    //獲得List集合
		   house =serRent.selectAll(currPage, PageUtil.pageSize);
		    return "succ";
		  
	  }

	   
	   public String del() {
		   //登录人删除登录人的房屋
		   UserRegs userRegs =(UserRegs)getSession().getAttribute("userRegs");
           int uid =userRegs.getUid();
           UserRegs users = new UserRegs();
		    users.setUid(uid);
		    int idd = Integer.parseInt(id);
           House house =new House();
		    house.setId(idd);
	            int falg= serRent.delXinXi(house);
	            
	            if(falg>0) {
	        	 return "succe";
	         }
	         return ERROR;
	   }
	   

	public List<House> getHouse() {
		return house;
	}




	public void setHouse(List<House> house) {
		this.house = house;
	}


	public int getCurrPage() {
		return currPage;
	}


	public void setCurrPage(int currPage) {
		this.currPage = currPage;
	}


	public String getPageIndex() {
		return pageIndex;
	}


	public void setPageIndex(String pageIndex) {
		this.pageIndex = pageIndex;
	}


	public String getId() {
		return id;
	}


	public void setId(String id) {
		this.id = id;
	}




	


	

	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
}
